package com.dayu.finecomm.utils;

/**
 * SEQ生成器
 * 
 * @author cjw
 *
 */
public class SequenceUtil {

	private static SequenceUtil instance = new SequenceUtil();

	private static int preSeq = 95;

	private static int valXy = 0;

	private SequenceUtil() {

	}

	public static SequenceUtil getInstance() {
		return instance;
	}

	public synchronized int getNextValue() {

		if (preSeq >= 111) {
			preSeq = 95;
		}
		preSeq = preSeq + 1;

		return preSeq;
	}

	/**
	 * rseq生成
	 * 
	 * @param pseq
	 *            初始值
	 * @return rseq
	 */
	public synchronized int getRseqYh(int pseq) {

		int rseq = pseq + 1;

		return rseq >= 112 ? 96 : rseq;
	}

	/**
	 * 获取兴源序号
	 */
	public synchronized int getValXy() {

		if (valXy >= 65530) {
			valXy = 0;
		}
		valXy = valXy + 1;

		return valXy;
	}

}
